using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using CoachingOrganizer.Logic.Models.Tools.MoneyCalculation;
using CoachingOrganizer.iOS.DataSources.Tools.MoneyCalculation;
using CoachingOrganizer.iOS.Helpers;

namespace CoachingOrganizer.iOS.Controllers.Tools.MoneyCalculation
{
    public partial class ResultsMoneyCalculationDetailsViewController : UIViewController
    {
        private readonly MoneyCalculationModel _model;

        public ResultsMoneyCalculationDetailsViewController(IntPtr handle)
            : base(handle)
        {
            _model = ((MoneyCalculationDetailsViewController)ParentViewController).Model;
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            PeriodSizeView.Source = new ReportPeriodSizesDataSource(PeriodSizeView, this, _model);
            PeriodView.Source = new ReportPeriodsDataSource(PeriodView, this, _model);
            UIHelper.RegisterCellClass(ReportView, ReportDataSource.CellIdentifer);
            ReportView.Source = new ReportDataSource(ReportView, this, _model);
            UpdatePeriodInfo();
        }

        private void UpdatePeriodInfo()
        {
            decimal totalIncomes = _model.Report.CurrentPeriodReport.GetTotalIncomes() ?? 0m;
            decimal totalSpents = _model.Report.CurrentPeriodReport.GetTotalSpents() ?? 0m;
            //IncomesSummaryView.Text=totalIncomes.ToString("c");
            //SpentsSummaryView.Text=totalSpents.ToString("c");
            //TotalSummaryView.Text = (totalIncomes - totalSpents).ToString("c");
        }

        partial void GoBack(NSObject sender)
        {
            ParentViewController.DismissViewController(true, null);
        }
    }
}